{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
	<h3 class="pb-3">编辑兑酒券</h3>
	<table class="layui-table layui-table-form">
		<tr>
			<td class="layui-td-gray-2">标题<font>*</font></td>
			<td><input type="text" name="title" lay-verify="required" lay-reqText="请完善标题" value="{$detail.title}"
					   autocomplete="off" placeholder="请输入标题" class="layui-input"></td>
		</tr>
		<tr>
		<tr>
			<td class="layui-td-gray-2">兑换量(ML)<font>*</font></td>
			<td><input type="text" name="money" lay-verify="required" lay-reqText="请完善优惠金额" value="{$detail.money}"
					   autocomplete="off" placeholder="请输入优惠金额" class="layui-input"></td>
		</tr>
		</tr>
		<tr>
			<td class="layui-td-gray-2">结束时间<font>*</font></td>
			<td><input type="text" name="end_time" lay-verify="required" lay-reqText="请完善结束时间"
					   value="{$detail.end_time|time_format=###,'Y-m-d'}" readonly readonly id="laydate_end_time"
					   autocomplete="off" placeholder="请选择" class="layui-input"></td>
		</tr>
		<tr>
			<td class="layui-td-gray-2">是否上架<font>*</font></td>
			<td>
				<input type="radio" name="status" value="1" title="是" {eq name="$detail.status" value="1" } checked{/eq}>
				<input type="radio" name="status" value="2" title="否" {eq name="$detail.status" value="2" } checked{/eq}>
			</td>
		</tr>
	</table>
	<div class="py-3">
		<input type="hidden" name="id" value="{$detail.id}"/>
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	var moduleInit = ['tool'];

	function gouguInit() {
		var form = layui.form, tool = layui.tool;
		//日期选择
		layui.laydate.render({
			elem: '#laydate_start_time' //指定元素
		});//日期选择
		layui.laydate.render({
			elem: '#laydate_end_time' //指定元素
		});


		//监听提交
		form.on('submit(webform)', function (data) {

			let callback = function (e) {
				layer.msg(e.msg);
				if (e.code == 0) {
					tool.sideClose(1000);
				}
			}
			tool.post("/admin/coupon/edit", data.field, callback);
			return false;
		});
	}
</script>
{/block}
<!-- /脚本 -->